<template>
  <el-container>
    <el-aside :width="themeStore.asideVisible ? '200px' : '64px'">Aside</el-aside>
    <el-container :class="{dark: themeStore.isDark}">
      <el-header :class="{dark: themeStore.isDark}">
        <div>
          <el-icon @click="themeStore.toggleAside()">
            <Switch />
          </el-icon>
          <el-icon @click="themeStore.toggleDark">
            <Sunny v-if="themeStore.isDark" />
            <Moon v-else />
          </el-icon>
          <el-icon @click="themeStore.toggleFullscreen()">
            <FullScreen />
          </el-icon>
        </div>
        <div>
          <el-icon @click="logout">
            <DeleteFilled />
          </el-icon>
        </div>
      </el-header>
      <el-main :class="{dark: themeStore.isDark}">
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script lang="ts" setup>
import {ref, reactive} from "vue";
import {useThemeStore} from "@/stores/themeStore";
import {Switch, Sunny, Moon, FullScreen, DeleteFilled} from "@element-plus/icons-vue";
import {useUserStore} from "@/stores/userStore";
import {useRouter} from "vue-router";

const themeStore = useThemeStore();
const userStore = useUserStore();
const router = useRouter()

const logout = () => {
  ElMessageBox.confirm(
    '确定要退出？',
    '温馨提示',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      userStore.setToken("")
      router.replace("/login")
    })
    .catch(() => {

    })
}
</script>

<style lang="scss" scoped>
.el-container {
  height: 100vh;
  overflow: hidden;

  .el-aside {
    background-color: rgba(0, 0, 0, 0.1);
    transition: width 0.3s;
  }

  .el-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: rgba(0, 0, 0, 0.5);
    padding: 0 15px;
    height: 50px;

    // 暗黑模式样式
    &.dark {
      background-color: rgba(255, 255, 255, 0.1); // 暗黑模式背景色
      color: #ffffff; // 暗黑模式文字颜色
    }
  }

  .el-main {
    padding: 25px;
    background-color: #f9f9f9;

    // 暗黑模式样式
    &.dark {
      background-color: #1e1e1e; // 暗黑模式背景色
      color: #ffffff; // 暗黑模式文字颜色
    }
  }
}
</style>